﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 1.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="IE=edge;text/html; charset=utf-8" />
<title>数据库测试主页</title>
<script type="text/javascript" src="/common/scripts/dynamicImportJs.js"></script>
<script>	
	loadScript("/common/scripts/jquery-min.js");
	loadScript("/lib/easyUI-1.4.5/easyui.js");
	loadScript("/common/scripts/common.js");
</script>
</head>
</head>
<body>
<table width="100%" height="100%" cellpadding="0" cellspacing="0">
<tr>
	<td height="40px" width="20%">
		<input type="button" style="width:100%; height:40px; font-size:16px;" value="新建数据库表" onClick="showCreateTable()"/>
	</td>
	<td id="contentTitle" style="font-size:16px;" align="center" >
		新建数据库表
	</td>
</tr>
<tr>
	<td >
	<table width="100%" height="100%">
		<tbody id="tables">
		</tbody>
	</table>
	</td>
	<td >
		<iframe id="dbContent" src="/watchDog/database/views/newTable.html" height="100%" width="100%" hspace="0" frameborder="0" marginheight="0" marginwidth="0">
		</iframe>
	</td>
</tr>
</table>

<script>
function requestTest()
{
	//alert("测试");
	var params = {
				"msgId":"getAllTables",
				"to":"tableManage",	
				"msg":{
					}
				};
	
	$.post("/watchDog/handleManage.req",JSON.stringify(params),function(result){
		$("#dbContent").html(result);
		
		var data = $.parseJSON(result);   
		
		
		if(!DealErrorInfo(data,'没有查到结果：'))
		{	
			return ; 
		}			
		
		var tables = data.msg.tables;
		if(typeof(tables) == "undefined" )
		{
			tables = [];
		}
		
		//alert(result);
		$("#tables").html("");
		for(var i=0;i<tables.length;i++)
		{
			var tableInfo = tables[i];
			var html = "<tr><td colspan=2 align='left'>" + tableInfo.tableName + "</td></tr>"
						+ "<tr><td width='30%'>&nbsp;</td><td onClick='showTableInfo(\""+ tableInfo.tableName + "\")'>表信息</td></tr>"
						+ "<tr><td width='30%'>&nbsp;</td><td onClick='showTableData(\""+ tableInfo.tableName + "\")'>表数据</td></tr>";
			$("#tables").append(html);
		}
		//$("#tables").html(JSON.stringify(data))												   
	});
}

function showCreateTable()
{
	$("#contentTitle").html("新建数据库表");
	$("#dbContent").attr("src","/watchDog/database/views/newTable.html");
}

function showTableInfo(tableName)
{
	$("#contentTitle").html(tableName + " 的表信息");
	$("#dbContent").height(500);
	$("#dbContent").attr("src","/watchDog/database/views/tableInfo.html?tableName="+tableName);
}


function showTableData(tableName)
{
	$("#contentTitle").html(tableName + " 的表数据");
	$("#dbContent").height(500);
	$("#dbContent").attr("src","/watchDog/database/views/tableData.html?tableName="+tableName);
}


requestTest();

</script>
</body>
</html>
